<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="All Rights Reserved, Copyright (C) 2013, Wuyeguo, Ltd." />
<title>EasyUI Web Admin Power by Wuyeguo</title>
<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../css/wu.css" />
<link rel="stylesheet" type="text/css" href="../css/icon.css" />
<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript" src="../jquery.easyui.min.js"></script>
<script type="text/javascript" src="../src/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../jquery.serializejson.min.js"></script>
<script type="text/javascript" src="../src/xheditor/xheditor-1.2.2.min.js"></script>
<script type="text/javascript" src="../src/xheditor/xheditor_lang/zh-cn.js"></script>
</head>
<body>
	<a href="javascript:;" onclick="go()" style="float: right;"><span style="color: red;font:700 24px/32px "";">←</span>返回</a>
	<div id="main">
		<h1 style="text-align: center;">我是标题</h1>
		<div style="height: 40px;">
			<h3 style="float: right;margin-right: 15px;">发布时间:2017-09-27</h3>
			<h3 style="float: right;margin-right: 15px;">类型:社会</h3>
			<h3 style="float: right;margin-right: 15px;">作者:Groots</h3>
		</div>

		<div style="padding-top: 20px;padding:20px;">
			反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格反过来看的风格
		</div>
	</div>
	<hr>
	评论区:
	<div id="comment" style="border: 1px dotted #666">
		 
	</div>
	<hr>
	<form  method="post" id="com">
		<textarea cols="150" rows="10" id="content" name="content"></textarea>
		<input type="text" name="newsID" id="newsID" style="display: none;">
	</form>
	<a href="javascript:;"  iconCls="icon-add" onclick="addComment()" plain="true" style="background: #1f637b;text-align: center;display: inline-block;width: 80px;color:#fff;border-radius:3px;">添加评论</a>



	<script type="text/javascript">
		
	
	 	var Request = new Object();
		id= GetRequest().id;//获取newsContent新闻内容模块传来改文章的id
	 	if(id){
	 		$.ajax({
				type:'post',
				url:'http://localhost:3000/news/data/'+id//请求news内容数据
			}).then(function(res){
				$.ajax({
					type:'post',
					url:'http://localhost:3000/cate/data/'+res.cateId//请求cate分类数据
				}).then(function(res1){
					var str='<h1 style="text-align: center;">'+res.title+'</h1><div style="height: 40px;"><h3 style="float: right;margin-right: 15px;">发布时间:'+res.date.substr(0,10)+'</h3><h3 style="float: right;margin-right: 15px;">类型:'+res1.text+'</h3><h3 style="float: right;margin-right: 15px;">作者:Groots</h3></div><div style="padding-top: 20px;padding:20px;">'+res.content+'</div>';
					$('#main').html(str);
				})
				$.ajax({
					type:'post',
					url:'http://localhost:3000/comment/list'//请求评论数据
				}).then(function(res2){
					var len=res2.rows.length;
					var str0=''
					for(var i=0;i<len;i++){
						if(res._id==res2.rows[i].newsID){//如果疲劳数据的类别属于改文章的类别，则加入改文章
							str0+='<div style="clear:both;border-bottom: 1px dashed #999"><p>'+res2.rows[i].content+'</p><span>评论时间：'+res2.rows[i].date.substr(0,10)+'</span></div>'
						}
					}
					$('#comment').html(str0);//加载数据到评论区
				});
				$('#newsID').val(res._id);//传入当前文章的id添加给当前评论的数据库、隐藏

			});
	 	}
		
	 	function addComment(){//提交新的评论
	 		$('#com').form('submit',{
		        onSubmit:function(){
		            if ($(this).form('enableValidation').form('validate')){
						$.ajax({
							type:"post",
							url:"http://localhost:3000/comment/data",
							data:$("#com").serializeJSON()
						}).then(function(res){
							var add='<div style="clear:both;border-bottom: 1px dashed #999"><p>'+$("#content").val()+'</p><span>评论时间：'+CurentTime()+'</span></div>';
							$('#comment').append(add);//当前编辑添加评论内容到评论区并传入数据库
							$("#content").val('');
						});
		            }
		        }
		    });
	 	}

		$('#content').xheditor({//编辑器加载
	        html5Upload: false,
	        upMultiple:1,


	        upLinkUrl:"/upload.php",
	        upLinkExt:"zip,rar,txt",

	        upImgUrl:"/uploadImg",
	        upImgExt:"jpg,jpeg,gif,png",
	        
	        upFlashUrl:"upload.php",
	        upFlashExt:"swf",
	        
	        upMediaUrl:"upload.php",
	        upMediaExt:"wmv,avi,wma,mp3,mid"
        });
       function GetRequest() {
		    var url = location.search; //获取url中"?"符后的字串
		    var theRequest = new Object();
		    if (url.indexOf("?") != -1) {
		        var str = url.substr(1);
		        strs = str.split("&");
		        for(var i = 0; i < strs.length; i ++) {
		            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
		        }
		    }
		    return theRequest;
		}
		function CurentTime(){//获取当前的年月日   
	        var now = new Date();
	        var year = now.getFullYear(); 
	        var month = now.getMonth() + 1; 
	        var day = now.getDate();    
	        var clock = year + "-"; 
	        if(month < 10)  
	            clock += "0"; 
	        clock += month + "-";  
	          
	        if(day < 10)  
	            clock += "0";     
	        clock += day + " ";  
	             
	        return(clock);   
		}
		function go(){//返回上一级的新闻内容
			addTab('新闻内容','../a_news/newsContent/index.html',null,1);
		}
		function addTab(title, href, iconCls, iframe){//切换iframe界面
			var tabPanel =parent.$('#wu-tabs');
			if(!tabPanel.tabs('exists',title)){
				var content = '<iframe scrolling="auto" frameborder="0"  src="'+ href +'" style="width:100%;height:100%;"></iframe>';
				if(iframe){
					tabPanel.tabs('add',{
						title:title,
						content:content,
						iconCls:iconCls,
						fit:true,
						cls:'pd3',
						closable:true
					});
				}
				else{
					tabPanel.tabs('add',{
						title:title,
						href:href,
						iconCls:iconCls,
						fit:true,
						cls:'pd3',
						closable:true
					});
				}
			}
			else
			{
				tabPanel.tabs('select',title);
				var current_tab=tabPanel.tabs('getSelected');
				tabPanel.tabs('update',{
					tab:current_tab,
					options:{
						content:'<iframe scrolling="auto" frameborder="0"  src="'+href+'" style="width:100%;height:100%;"></iframe>'
					}
				});
			}
		}	 
	</script>
</body>
</html>